package educrypt.gui.components;

import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Font;
import java.awt.Window;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;

import educrypt.gui.view.TextPreviewView;
import educrypt.i18n.Messages;

class TextPreviewDialog extends EducryptDialog implements TextPreviewView {

	private static final long serialVersionUID = 8200696352381662957L;

	private final JPanel contentPanel = new JPanel();
	private JScrollPane scrollPane;
	private JTextArea txtPreview;

	public TextPreviewDialog(Window owner) {
		super(owner);

		this.setSize(650, 700);
		this.setPreferredSize(this.getSize());

		setTitle(Messages.getString("guiTextPreview")); //$NON-NLS-1$

		getContentPane().setLayout(new BorderLayout());
		// contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
		getContentPane().add(contentPanel, BorderLayout.CENTER);
		contentPanel.setLayout(null);

		JLabel lblTextPreview = new JLabel(Messages.getString("guiTextPreview")); //$NON-NLS-1$
		lblTextPreview.setFont(new Font("Tahoma", Font.BOLD, 15));
		lblTextPreview.setBounds(10, 11, 378, 24);
		contentPanel.add(lblTextPreview);

		scrollPane = new JScrollPane((Component) null);
		scrollPane.setBounds(47, 46, 550, 600);
		contentPanel.add(scrollPane);

		txtPreview = new JTextArea();
		scrollPane.setViewportView(txtPreview);
	}

	@Override
	public void showPreview(String text) {
		txtPreview.setText(text);
		super.open();
	}
}
